package com.lianxueda.drawing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lianxueda.drawing.domain.pojo.WxLeave;
import com.lianxueda.drawing.domain.vo.LeaveVo;
import com.lianxueda.drawing.mapper.WxLeaveMapper;
import com.lianxueda.drawing.service.WxLeaveService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WxLeaveServiceImpl extends ServiceImpl<WxLeaveMapper, WxLeave>
        implements WxLeaveService {

    @Resource
    private WxLeaveMapper wxLeaveMapper;


    /**
     *
     * @param page  页码
     * @param pageSize  每页记录数
     * @return  封装总记录数和一页的数据对象
     */
    @Override
    public LeaveVo selectLeavePage(Integer page, Integer pageSize) {
        Long total = wxLeaveMapper.selectLeaveCount();

        int startIndex = (page - 1) * pageSize;

        List<WxLeave> leaveList = wxLeaveMapper.selectLeavePage( startIndex, pageSize);

        LeaveVo leaveVo = new LeaveVo();
        leaveVo.setTotal(total);
        leaveVo.setRow(leaveList);

        return leaveVo;

    }
}